import service from '@/utils/axios'
import baseURL from '@/ipconfig'
let $http = ''
console.log(process.env.NODE_ENV)
if (process.env.NODE_ENV === 'production') {
  $http = (params) => {
    params.url = baseURL.api + params.url
    return service(params)
  }
} else {
  $http = Object.keys(baseURL.proxy).reduce((cur, item) => {
    cur[item] = function(params) {
      params.url = `/${item}` + params.url
      return service(params)
    }
    return cur
  }, {})
}

export default $http

